package com.zyh.homework.test3;

import com.zyh.homework.test3.domain.Student;

/**
 * @Author zyh
 * @Date 2024/7/29
 * @Description 按照以下描述完成类的定义。
 * 		学生类属性：姓名name 年龄age 成绩score
 * 			行为：吃饭eat()
 * 			      stuty(String content)(content:表示学习的内容)
 *      2.定义学生工具StudentsTool,有四个方法,描述如下
 *      	public void listStudents(Student[] arr):遍历打印学生信息
 *      	public int getMaxScore(Student[] arr):获取学生成绩的最高分
 *      	public Student getMaxStudent(Student[] arr):获取成绩最高的学员
 *      	public int getAverageScore(Student[] arr):获取学生成绩的平均值
 *      	public int getCount(Student[] arr):获取不及格的学员数量
 *      3.定义测试类TestStudentTool，在main方法中首先创建长度为5的Student数组并初始化数据,再创建StudentsTool类的对象,并调用以上方法
 */
public class Test3 {
    public static void main(String[] args) {
        Student[] students = new Student[5];
        Student student1 = new Student("zyh",20,46);
        Student student2 = new Student("jyh",21,65);
        Student student3 = new Student("mjd",22,25);
        Student student4 = new Student("cxk",23,56);
        Student student5 = new Student("dz",24,15);
        students[0]=student1;
        students[1]=student2;
        students[2]=student3;
        students[3]=student4;
        students[4]=student5;
        StudentsTool studentsTool = new StudentsTool();
        //遍历打印学生信息
        System.out.println("学生信息如下：");
        studentsTool.listStudents(students);
        //获取学生最高分数
        int maxScore = studentsTool.getMaxScore(students);
        System.out.println("最高分是：" + maxScore);
        //获取成绩最高的学员
        Student maxStudent = studentsTool.getMaxStudent(students);
        System.out.println("成绩最高的学员是："+maxStudent.getName());
        //获取成绩平均值
        int averageScore = studentsTool.getAverageScore(students);
        System.out.println("成绩平均值是："+averageScore);
        //获取不及格的人数
        int count = studentsTool.getCount(students);
        System.out.println("不及格有"+count+"人");
    }
}
